package com.maiji.cloud.controller;

import com.maiji.cloud.entities.community.ComMiddleLabel;
import com.maiji.cloud.request.BaseDataReqDto;
import com.maiji.cloud.response.BaseResDto;
import com.maiji.cloud.response.Status;
import com.maiji.cloud.service.ComMidLabelService;
import org.eclipse.jetty.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/comMidLabel")
public class ComMidLabelController {

    @Autowired
    private ComMidLabelService comMidLabelService;

    /**
     * 编辑动态标签
     * @param baseDataReqDto
     * @return
     */
    @PostMapping("/editComMiddleLabel")
    public BaseResDto editComMiddleLabel (@RequestBody BaseDataReqDto<ComMiddleLabel> baseDataReqDto) {
        ComMiddleLabel comMiddleLabel = baseDataReqDto.getData();
        if (comMiddleLabel.getLabelId() == null) return new BaseResDto(Status.ERROR);
        if (StringUtil.isBlank(comMiddleLabel.getMsgId())) return new BaseResDto(Status.ERROR);
        return comMidLabelService.editComMiddleLabel(comMiddleLabel);
    }

}

